﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MxWeiXinPF.BLL
{
     public class WXLogs
    {

        #region  不带wid的日志记录
        public static void AddLog(string content, string openid = "")
        {
            AddLog("", "", content, openid);
        }
        public static void AddErrLog(string content, string openid = "")
        {
            AddLog("", "", content, 0, openid);
        }
        public static void AddLog(string modelName, string funName, string content, string openid = "")
        {
            AddLog(modelName, funName, content, 1, openid);
        }
        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="modelName">模块名称</param>
        /// <param name="funName">方法名称</param>
        /// <param name="content">日志内容</param>
        /// <param name="logsType">日志类型（0错误，1正常）</param>
        public static void AddLog(string modelName, string funName, string content, int logsType, string openid = "")
        {

             AddLog(modelName, funName, content, logsType, "", openid);
        }

        /// <summary>
        /// 添加flg标志
        /// </summary>
        /// <param name="modelName"></param>
        /// <param name="funName"></param>
        /// <param name="flg"></param>
        public static void AddFlg(string modelName, string funName, string flg, string openid = "")
        {
            AddLog(modelName, funName, "", 1, flg, "", openid);
        }

        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="modelName">模块名称</param>
        /// <param name="funName">方法名称</param>
        /// <param name="content">日志名称</param>
        /// <param name="logsType">日志类型（0错误，1正常）</param>
        /// <param name="flg">标志</param>
        public static void AddLog(string modelName, string funName, string content, int logsType, string flg, string openid = "")
        {
             AddLog(modelName, funName, content, logsType, flg, "", openid);
        }


        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="modelName">模块名称</param>
        /// <param name="funName">方法名称</param>
        /// <param name="content">日志名称</param>
        /// <param name="logsType">日志类型（0错误，1正常）</param>
        /// <param name="flg">标志</param>
        /// <param name="flg2">标志2</param>
        public static void AddLog(string modelName, string funName, string content, int logsType, string flg, string flg2, string openid)
        {
             MxWeiXinPF.DAL.wx_logs dal=new MxWeiXinPF.DAL.wx_logs();

            Model.wx_logs log = new Model.wx_logs();
            log.modelName = modelName;
            log.funName = funName;
            log.logsContent = content;
            log.logsType = logsType;
            log.flg = flg;
            log.flg2 = flg2;
            log.createDate = DateTime.Now;
            log.openid = openid;
            dal.Add(log);
        }

        /// <summary>
        /// 是否存在标志flg
        /// </summary>
        /// <param name="flg"></param>
        /// <returns></returns>
        public static bool ExistsFlg(string flg)
        {
            MxWeiXinPF.DAL.wx_logs dal = new MxWeiXinPF.DAL.wx_logs();
            return dal.ExistsFlg(flg);
        }

        #endregion  ExtensionMethod

        #region  带wid的日志记录

        #region 错误信息记录
        /// <summary>
        /// 添加日志：错误的
        /// </summary>
        /// <param name="wid">微帐号</param>
        /// <param name="content">日志内容</param>
        public static void AddErrLog(int wid, string content, string openid = "")
        {
            AddErrLog(wid, "", "", content, openid);
        }


        /// <summary>
        /// 添加日志：错误的
        /// </summary>
        /// <param name="wid">微帐号</param>
        /// <param name="modelName">模块名称</param>
        /// <param name="funName">方法名称</param>
        /// <param name="content">日志内容</param>
        public static void AddErrLog(int wid, string modelName, string funName, string content, string openid = "")
        {
            AddLog(wid, modelName, funName, content, 0, openid);
        }


        public static void AddFlg(int wid, string modelName, string funName, string flg, string openid = "")
        {
            AddLog(wid, modelName, funName, "", 1, flg, "", openid);
        }


        #endregion


        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="wid"></param>
        /// <param name="content"></param>
        public static void AddLog(int wid, string content, string openid = "")
        {
            AddLog(wid, "", "", content, openid);
        }

        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="wid">微帐号</param>
        /// <param name="modelName">模块名称</param>
        /// <param name="funName">方法名称</param>
        /// <param name="content">日志内容</param>
        public static void AddLog(int wid, string modelName, string funName, string content, string openid = "")
        {
            AddLog(wid, modelName, funName, content, 1, openid);
        }

     

        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="wid">微帐号</param>
        /// <param name="modelName">模块名称</param>
        /// <param name="funName">方法名称</param>
        /// <param name="content">日志内容</param>
        /// <param name="logsType">日志类型（0错误，1正常）</param>
        public static void AddLog(int wid, string modelName, string funName, string content, int logsType,string openid="")
        {
           AddLog(wid, modelName, funName, content, logsType, "", openid);
        }

        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="modelName">模块名称</param>
        /// <param name="funName">方法名称</param>
        /// <param name="content">日志名称</param>
        /// <param name="logsType">日志类型（0错误，1正常）</param>
        /// <param name="flg">标志</param>
        public static void AddLog(int wid, string modelName, string funName, string content, int logsType, string flg,string openid)
        {
            AddLog(wid, modelName, funName, content, logsType, flg, "", openid);
        }


        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="modelName">模块名称</param>
        /// <param name="funName">方法名称</param>
        /// <param name="content">日志名称</param>
        /// <param name="logsType">日志类型（0错误，1正常）</param>
        /// <param name="flg">标志</param>
        /// <param name="flg2">标志2</param>
        public static void AddLog(int wid, string modelName, string funName, string content, int logsType, string flg, string flg2,string openid)
        {
            try
            {
                MxWeiXinPF.DAL.wx_logs dal = new MxWeiXinPF.DAL.wx_logs();

                Model.wx_logs log = new Model.wx_logs();
                log.wid = wid;
                log.modelName = modelName;
                log.funName = funName;
                log.logsContent = content;
                log.logsType = logsType;
                log.flg = flg;
                log.flg2 = flg2;
                log.createDate = DateTime.Now;
                log.openid = openid;
                dal.Add(log);
            }
            catch (Exception ex)
            {

            }
            
        }

        #endregion  ExtensionMethod

    }
}
